import java.util.ArrayList;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description: 判断回文链表
 * User: wangxin
 * Date: 2024-10-26
 * Time: 22:43
 */

  class ListNode {
    int val;
    ListNode next = null;
    public ListNode(int val) {
      this.val = val;
        }
  }

public class test {
    public boolean isPail (ListNode head) {
        // write code here
        if(head == null){
            return false;
        }
        if(head.next == null){
            return true;
        }
        ArrayList<Integer> arr = new ArrayList<>();
        while(head != null){
            arr.add(head.val);
            head = head.next;
        }
        int left = 0;
        int right = arr.size() - 1;
        while(left < right){
            int a = arr.get(left);
            int b = arr.get(right);
            if(a != b){
                return false;
            }
            left++;
            right--;
        }
        return true;

    }

    public static void main(String[] args) {

        ListNode head = new ListNode(-401261);
        ListNode head1 = new ListNode(-449050);
        ListNode head2 = new ListNode(-456674);
        ListNode head3 = new ListNode(-456674);
        ListNode head4= new ListNode(-449050);
        ListNode head5 = new ListNode(-401261);
        head.next = head1;
        head1.next = head2;
        head2.next = head3;
        head3.next = head4;
        head4.next = head5;



    }
}
